package com.cupk.service;

import com.cupk.entity.User;
import com.cupk.repository.UserRepository;

import java.util.List;

/**
 * @author LY
 * @version 1.0
 */
public class UserService {

    private UserRepository userRepository = new UserRepository();

    public UserService() {
    }

    //登录
    public User login(String username, String password) {
        return userRepository.login(username, password);
    }

    //列出所有用户
    public List<User> findAll() {
        return userRepository.findAll();
    }

    //列出所有用户
    public User findById(Integer id) {
        return userRepository.findById(id);
    }

//    //根据用户id影片id查找相关记录
//    public String recordSearch(Integer userId, Integer id){
//        return userRepository.recordSearch(userId,id);
//    }

    //更新用户评分
    public void renewRecords(String records, Integer id){
        userRepository.renewRecords(records,id);
    }

    //添加新的收藏记录
    public void addCollectible(Integer userId,String newCollect){
        userRepository.addCollectible(userId,newCollect);
    }

    //注册用户
    public void register(String username,String password,String hobbies){
        userRepository.register(username,password,hobbies);
    }

    //修改个人信息
    public void editInformation(Integer userId,String username,String password,String hobbies){
        userRepository.editInformation(userId,username,password,hobbies);
    }

    //删除收藏记录
    public void deleteCollect(String collectible, Integer userId){
        userRepository.deleteCollect(collectible,userId);
    }
}
